#ifndef UTIL_H
#define UTIL_H

#include <opencv2/opencv.hpp>
#include <QImage>
#include <memory>
#include <sys/stat.h>

class Util
{
public:
	static bool IsLittleEndian();
	static void Int2Char4(int i, char c[4]);
	static void Char42Int(int& i, const char c[4]);
	static void DrawImageOnCanvas(cv::OutputArray& canvas, cv::InputArray& image, cv::InputArray& alpha);
    static std::unique_ptr<QImage> CvImage2QImage(const cv::Mat &src);
	static inline bool IsFileExist (const std::string& name) {
		struct stat buffer{};
		return (stat (name.c_str(), &buffer) == 0);
	}
};

class StrException : std::exception
{
private:
    std::string w;
public:
    explicit StrException(const std::string& str)
    {
        w = str;
    }
    const char* what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW final
    {
        return w.c_str();
    }
};

struct McsImportArgs
{
	QString bodyPath = "";
	QString shadowPath = "";
	QString remapPath = "";
	QString bodyFileName = "";
	QString shadowFileName = "";
	QString remapFileName = "";
	int width = 0;
	int height = 0;
	int frameCount = 0;
	bool isWithShadow = false;
	bool isWithRemap = false;
	bool isFileNameFormZero = false;
};

#endif //UTIL_H
